<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    
    <title>Form Layouts</title>
    <link href="/public/js/summernote/dist/summernote.css" rel="stylesheet">
    <!--multi-select-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-multi-select/css/multi-select.css" />
    <!--tags input-->
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-tags-input/jquery.tagsinput.css" />
    <script language="javascript">
        function RunOnBeforeUnload() {window.onbeforeunload = function(){ return ""; } }
    </script>
    <?php $this->load->view('library/header');?>
</head>

<body onload="RunOnBeforeUnload()" class="sticky-header">

<?php $this->load->view('library/left');?>

<!-- main content start-->
<div class="main-content" >
    
    <?php $this->load->view('library/top');?>
    
    <!-- page heading start-->
    <div class="page-heading">
        <h3>
            添加商品
        </h3>
        <ul class="breadcrumb">
            <li>
                <a href="#">Forms</a>
            </li>
            <li class="active"> Forms Layouts </li>
        </ul>
    </div>
    <!-- page heading end-->
    
    <!--body wrapper start-->
    <section class="wrapper">
        <div class="row">
            <div class="col-md-12">
                <!-- page start-->
                <section class="panel">
                    <header class="panel-heading custom-tab turquoise-tab">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#home2" data-toggle="tab">站点信息</a>
                            </li>
                            <li class="">
                                <a href="#about2" data-toggle="tab">其他信息</a>
                            </li>
                        </ul>
                    </header>
                    <form id="commentForm" class="form-horizontal adminex-form" method="post">
                        <div class="panel-body">
                            <div class="tab-content">
                                <div class="tab-pane active" id="home2">
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">站点名称</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['web_name'];?>" name="web_name" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">产品前缀</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['title'];?>" name="title" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">货号前缀</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['ab_name'];?>" name="ab_name" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">网站API</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['web_access'];?>" name="web_access" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">Ga跟踪号</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['view_id'];?>" name="view_id" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">排序</label>
                                        <div class="col-lg-10">
                                            <input class=" form-control" value="<?php echo $web_info['sort_num'];?>" name="sort_num" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">站点类型</label>
                                        <div class="col-lg-10">
                                            <select class=" form-control" name="type" >
                                                <option <?php if ($web_info['type'] == 1) { echo 'selected';}?> value="1">Shopify</option>
                                                <option <?php if ($web_info['type'] == 2) { echo 'selected';}?> value="2">Bigcommerce</option>
                                                <option <?php if ($web_info['type'] == 3) { echo 'selected';}?> value="3">Ueeshop</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="about2">
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">产品分类</label>
                                        <div class="col-md-10">
                                            <select id="cate" multiple class="form-control m-bot15">
                                                <option value="">顶级分类</option>
                                                <?php foreach ($web_info['info']['cate_arr'] as $cate) :?>
                                                    <option value="<?php echo $cate;?>"><?php echo $cate;?></option>
                                                <?php endforeach;?>
                                            </select>
                                            <div class="col-md-4" style="margin-left: -15px;">
                                                <input type="text" id="cate_name" class="form-control" placeholder="填写分类名称">
                                            </div>
                                            <div class="col-md-4">
                                                <button class="btn btn-info" id="add_cate" type="button">确认添加</button>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group ">
                                        <label for="cname" class="control-label col-lg-2">产品TAGS</label>
                                        <div class="col-md-10">
                                            <input id="tags_1" type="text" class="tags" name="tags" value="<?php echo $web_info['info']['tags'];?>" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <footer class="panel-footer">
                            <button type="submit" name="handle_type" value="0" class="btn btn-post pull-right btn-big">提交信息</button>
                            <ul class="nav nav-pills p-option"></ul>
                        </footer>
                    </form>
                </section>
                <!-- page end-->
            </div>
        </div>
    </section>
    <!--body wrapper end-->
    
    <!--footer section start-->
    <footer>
        2014 &copy; AdminEx by
    </footer>
    <!--footer section end-->


</div>
<!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<!--编辑器-->
<script src="/public/js/summernote/dist/summernote.js"></script>
<script src="/public/js/summernote/dist/lang/summernote-zh-CN.js"></script>

<!--multi-select-->
<script type="text/javascript" src="/public/js/jquery-multi-select/js/jquery.multi-select.js"></script>
<script type="text/javascript" src="/public/js/jquery-multi-select/js/jquery.quicksearch.js"></script>
<script src="/public/js/multi-select-init.js"></script>

<!--tags input-->
<script src="/public/js/jquery-tags-input/jquery.tagsinput.js"></script>
<script src="/public/js/tagsinput-init.js"></script>

<script src="/public/js/nestable/jquery.nestable.js"></script>
<script src="/public/js/nestable-init.js"></script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

<script>

    jQuery(document).ready(function(){
        
        $('#add_cate').click(function () {
            var cate_name = $('#cate_name').val();
            $('#cate_name').val('');
            if (cate_name) {
                $('#cate').append('<option value="'+cate_name+'">'+cate_name+'</option>');
            }
        });

        $('#summernote').summernote({
            tabsize: 2,
            height: 300,
            lang: 'zh-CN'
        });

        $('#commentForm').submit(function () {

            t = setTimeout(function() {
                $('.panel-footer .btn-big').attr('disabled','disabled').addClass('btn-submit-disabled').html('正在提交，请稍等...');
            }, 200);

            var data = new FormData(this);
            $("#cate option:not(:selected)").each(function (i) {
                var val = $(this).attr('value');
                if (val) {
                    data.append("cate[]", val);
                }
            });

            $.ajax({
                type: 'POST',
                url: '<?php echo base_url('siteweb/set'. ($web_info ? "/web_id/{$web_info['web_id']}" : ''));?>',
                data: data,
                success: function (data) {
                    clearTimeout(t);
                    if (data.status != 'success') {
                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: 1500,
                            showConfirmButton: false
                        });
                        $('.panel-footer .btn-big').attr("disabled",false).removeClass('btn-submit-disabled').html('提交信息');
                    } else {
                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: data.stop ? data.stop : 1500,
                            showConfirmButton: false
                        }).then(function(isConfirm) {
                            window.onbeforeunload = '';
                            window.location.href = '<?php echo base_url('siteweb/index');?>';
                        });
                        $('.panel-footer .btn-big').removeClass('btn-submit-disabled').html(data.info);
                    }

                },
                dataType:'json',
                cache: false,
                contentType: false,
                processData: false
            });

            return false;
        });
    });
</script>

</body>
</html>
